package top.yxf.spring.beans.factory.support;

import top.yxf.spring.BeansException;
import top.yxf.spring.beans.factory.config.BeanDefinition;
import top.yxf.spring.beans.factory.config.SingletonBeanRegistry;

import java.util.HashMap;
import java.util.Map;

/**
 * @author xs.wu
 */
public class DefaultSingletonBeanRegistry  implements SingletonBeanRegistry {

    private final Map<String, BeanDefinition> singletonMap = new HashMap<>();

    public void addSingleton(String beanName, BeanDefinition beanDefinition) {
        singletonMap.put(beanName, beanDefinition);
    }
    @Override
    public Object getSingleton(String beanName) throws BeansException {
        return singletonMap.get(beanName);
    }
}
